<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Members extends Model
{
    //

    public function plus($data)
    {
        if (isset($data['id'])) {
            unset($data['id']);
        }
        if ($this->phoneNumber($data['username']) === false) {
            return false;
        }
        $this->username = $data['username'];
        $this->pwd = md5($data['pwd']);
        $this->save();
        return true;
    }


    /**
     * Instructions:手机号码验证
     * Author: Vijay  <1937832819@qq.com>
     * Time: 2018/11/21 9:17
     * @param $phone
     * @return bool
     */
    public function phoneNumber($phone)
    {
        if (preg_match("/^1[345678]{1}\d{9}$/", $phone)) {
            return true;
        }
        return false;
    }
}
